// H5 plus事件处理
function plusReady() {
	init();
	// 设置系统状态栏背景为红色
	plus.navigator.setStatusBarBackground("#e84d3f");
	//监听页面返回显示事件
	window.addEventListener('preshow', function(event) {
		if(plus.webview.getDisplayWebview()[0].id != "Hbuilder") {
			init();
		}
	});
	window.addEventListener('show', function(event) {
		console.log(plus.webview.getDisplayWebview()[0].id);
		init();
	});
	plus.navigator.setCookie(base_url, plus.storage.getItem('cookie'));
}
//初始化事件
function init() {
	plus.navigator.setStatusBarBackground("#e84d3f");
}
mui.ready(function() {

	setTimeout(function() {
		mui.preload({
			url: "goods.html?id=2",
			id: "goods.html?id=2",
			extras: {
				catid: 2
			},
		});
		mui.preload({
			url: "goods.html?id=12",
			id: "goods.html?id=12",
			extras: {
				catid: 12
			},
		});
		mui.preload({
			url: "goods.html?id=5",
			id: "goods.html?id=5",
			extras: {
				catid: 5
			},
		});
		mui.preload({
			url: "goods.html?id=18",
			id: "goods.html?id=18",
			extras: {
				catid: 18
			},
		});
	}, 1000);

	setTimeout(function() {
		mui.preload({
			url: "login.html",
			id: "login.html",
		});
	}, 1000);
	setTimeout(function() {
		mui.preload({
			url: "mycenter.html",
			id: "mycenter.html",
		});
	}, 1000);
	/**
	 * 综合便利店
	 */
	document.getElementById('bm-5').addEventListener('tap', function() {
		openNewWindows('goods.html?id=2', { catid: 2 });
	});
	/**
	 * 便民餐厅
	 */
	document.getElementById('bm-6').addEventListener('tap', function() {
		openNewWindows('goods.html?id=12', { catid: 12 });
	});
	/**
	 * 咖啡吧
	 */
	document.getElementById('bm-3').addEventListener('tap', function() {
		openNewWindows('goods.html?id=5', { catid: 5 });
	});
	/**
	 * 母婴
	 */
	document.getElementById('bm-4').addEventListener('tap', function() {
		openNewWindows('goods.html?id=18', { catid: 18 });
	});
	$('.login').on('tap', function() {
		is_login();
		if(plus.storage.getItem('mobile') == 0) {
			openNewWindows('login.html');
			return false;
		}
		return false;
	});
})
if(window.plus) {
	plusReady();
} else {
	document.addEventListener("plusready", plusReady, false);
}